package com.itcoon.cloud.framework.temporal;/**
 * @author Athric Yu
 * 2024/11/15
 **/

import com.itcoon.cloud.framework.properties.TemporalPatternConfigProperties;

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/**
 *
 *
 * @author Athric Yu
 * 2024/11/15
 **/
public class StringZonedDateTimeConverter extends AbstractConverter<String, ZonedDateTime>{

    public StringZonedDateTimeConverter(TemporalPatternConfigProperties.TemporalSerialization<String, ZonedDateTime> temporalSerialization) {
        super(temporalSerialization);
    }

    @Override
    public ZonedDateTime parse(String source) {
        return ZonedDateTime.parse(source, DateTimeFormatter.ofPattern(temporalSerialization.getPattern()));
    }

    @Override
    public String format(ZonedDateTime temporal) {
        return temporal.format(DateTimeFormatter.ofPattern(temporalSerialization.getPattern()));
    }
}
